package com.chixing.controller;

import com.chixing.pojo.Customer;
import com.chixing.service.PersonalcenterService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

@Controller
public class PersonalcenterController {

    @Autowired
    private PersonalcenterService personalcenterService;

    @GetMapping("index/personalCenter")
    public ModelAndView getById(HttpSession session){
        Customer customer = (Customer) session.getAttribute("loginCustomer");
        ServerResponse serverResponse = personalcenterService.getById(customer.getCusId());
        ModelAndView mav = new ModelAndView();
        mav.addObject("serverResponse",serverResponse);

        mav.setViewName("users/personal_center");
        return mav;
    }

}
